import datetime

from django.contrib.auth.models import AbstractUser
from django.db import models

# Create your models here.
from django.utils import timezone


class Users(AbstractUser):
    """
    用户信息表
    """
    ROLE_TYPE = (
        (1, '普通用户'),
        (2, '骑手'),
    )

    real_name = models.CharField(max_length=20, verbose_name='真实姓名', null=True)
    birthday = models.DateTimeField(verbose_name='用户生日', null=True)
    head_img = models.ImageField(upload_to='upload_images/user_pictures', verbose_name='用户头像', default='upload_images/user_pictures/default_avatar/default_head_img.jpg')
    phone = models.CharField(max_length=11, verbose_name='电话号码', null=False)
    role_type = models.SmallIntegerField(verbose_name='用户类型', null=False, default=1, choices=ROLE_TYPE)

    def __str__(self):
        return self.username

class VerifyCode(models.Model):
    """
    验证码
    """
    code = models.CharField(verbose_name="验证码", max_length=10)
    phone = models.CharField(verbose_name="电话", max_length=11)
    add_time = models.DateTimeField(verbose_name="添加时间", auto_now=True)

    class Meta:
        verbose_name = "短信验证"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.code